package cn.hyh.core.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.sql.SQLOutput;

/**
 * @auther :hyh
 * @desc :   springmvc 的相关的配置
 * @date :2019/7/25
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Value("${imgAccess.path}")
    private String imgAccessPath;    //         /imgs/**

    @Value("${spring.servlet.multipart.location}")//   D:/static/
    private String  imgsLoaction;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //将图片的访问路径 映射到指定到具体的 静态资源路径。                将存放上传图片的目录变为静态资源目录。
        registry.addResourceHandler(imgAccessPath).addResourceLocations("file:"+imgsLoaction);
    }
}
